﻿package commands 
{
	import flash.utils.ByteArray;
	import commands.classesinfo.*;
	
	/**
	 * ...
	 * @author wwx
	 * 10000100 充值
	 */
	public class RechargeCmdReq extends abCommand 
	{
		
		public function RechargeCmdReq() 
		{
			super(CommandType(CommandType.CMD_TYPE_ADDCHIP_REQ));
			msgSeq = 10000100;
		}
		
		private var msgSeq:int;//消息号
		public var reserve:int;//保留字段
		
		public var managerAccountNum:String;//管理员帐号
		public var managerPassword:String;//管理员密码
		public var roomId:int;//房间id
		public var playerAccountNum:String;//玩家帐号
		public var rechargeTime:int;//充值时间
		public var rechargeChips:int;//充值数量
		
		public function convertToBytes(bytes:ByteArray, offset:int):int
		{
			BytesValueConverter.writeIntToBytes(bytes, offset, msgSeq);
			offset += 4;
			BytesValueConverter.writeIntToBytes(bytes, offset, reserve);
			offset += 4;
			
			BytesValueConverter.writeShortToBytes(bytes, offset, managerAccountNum.length);
			offset += 2;
			bytes.writeMultiByte(managerAccountNum, "gb2312");
			offset += managerAccountNum.length;		
			
			BytesValueConverter.writeShortToBytes(bytes, offset, managerPassword.length);
			offset += 2;
			bytes.writeMultiByte(managerPassword, "gb2312");
			offset += managerPassword.length;	
			
			BytesValueConverter.writeIntToBytes(bytes, offset, roomId);
			offset += 4;
			
			BytesValueConverter.writeShortToBytes(bytes, offset, playerAccountNum.length);
			offset += 2;
			bytes.writeMultiByte(playerAccountNum, "gb2312");
			offset += playerAccountNum.length;				
			
			BytesValueConverter.writeIntToBytes(bytes, offset, rechargeTime);
			offset += 4;
			
			BytesValueConverter.writeIntToBytes(bytes, offset, rechargeChips);
			offset += 4;			
			
			bytes.position = offset;
			bytes.length = offset;
			
			return offset;
		}		
	}
	
}